import styles from '../styles.less';
import { Button } from 'antd';
import { useAccess, Access } from 'umi';
import {AppstoreOutlined} from "@ant-design/icons";

const Opera = (props) => {

  const { setDataForm, setRecord } = props.data;
  const access = useAccess();

  function add(e) {
    e.preventDefault();
    setDataForm({
      visible: true,
      title: '添加操作',
      data: undefined,
    });
  }

  function recodTable(e) {
    e.preventDefault();
    setRecord({
      visible: true,
      title: '领取记录',
      data: undefined,
    });
  }

  return (
    <div className={styles.myOperaAction}>
      <div className={styles.leftContent}>
        <Access accessible={access?.coupon_info_add ?? false}>
          <Button type="primary" onClick={add}>
            新增
          </Button>
        </Access>
        <Access accessible={access?.campain_saler_list ?? false}>
          <Button type='primary' ghost onClick={recodTable} icon={<AppstoreOutlined/>}>
            领取记录
          </Button>
        </Access>
      </div>
    </div>
  );
};

export default Opera;
